<?php

/**
 * Formulário de criação de novas tarefas
 * 
 * Implementa App_Interfaces_IForms
 * 
 * @author Ricardo Simão
 * 
 * @version 1.1
 *
 */
class App_Forms_NewTask extends App_Forms_TemplateAbstract  implements App_Interfaces_IForms {
	
	/**
	 * Assunto da tarefa
	 *
	 * @var string
	 */
	protected $assunto;
	
	/**
	 * Texto da tarefa
	 *
	 * @var string
	 */
	protected $tarefa;
	
	/**
	 * Utilizadores registados no sistema
	 *
	 * @var string
	 */
	protected $users;
	
	/**
	 * Tabela onde estão guardados os dados dos utilizadores
	 *
	 * @var string
	 */
	protected $table;
	
	/**
	 * Data para a conclusão da tarefa
	 *
	 * @var string
	 */
	protected $date;
	
	/**
	 * Botão de envio
	 *
	 * @var mixed
	 */
	protected $submit;
	
	
	
	/**
	 * Formulário de criação de novas tarefas
	 *
	 * @return Zend_Form
	 */
	public static function getForm() {
		
		$assunto = new Zend_Form_Element_Text ( 'assunto' );
		$assunto->setLabel ( 'Assunto:' )
				->setRequired ( true )
				->setAttrib ( 'size', 80 )
				->setAttrib ( 'class', self::CLASS_BOX_TYPE_LARGE )
				->setErrorMessages ( array (self::ERR_EMPTY_FIELD ) );
		
		$tarefa = new Zend_Form_Element_Textarea ( 'tarefa' );
		$tarefa->setLabel ( 'Tarefa:' )
				->setAttrib ( 'class', self::CLASS_BOX_TYPE_LARGE )
				->setRequired ( true )
				->setErrorMessages ( array (self::ERR_EMPTY_FIELD ) )
				->setAttrib ( 'rows', 10 )
				->setAttrib ( 'cols', 70 );
		
		$users = new Zend_Form_Element_Select ( 'users' );
		$users->setLabel ( 'Atribuir tarefa a:' )
				->setRequired ( TRUE )
				->setAttrib ( 'class', self::CLASS_BOX_TYPE_LARGE )
				->setErrorMessages ( array (self::ERR_EMPTY_FIELD ) );
		
		$table = new App_UserService ( );
		foreach ( $table->getAllUsers () as $c ) {
			$users->addMultiOptions ( array ($c->real_name .'_'.$c->email => $c->real_name ) );
		}
		
		$date = new Zend_Form_Element_Text ( 'date_new_task' );
		$date->setLabel ( 'Data limite para a conclusão da tarefa:' )
				->setAttrib ( 'class', self::CLASS_BOX_TYPE_LARGE )
				->setAttrib ( 'size', 10 )
				->setRequired ( true )
				->setErrorMessages ( array (self::ERR_EMPTY_FIELD ) );
		
		$submit = new Zend_Form_Element_Submit ( 'submit' );
		$submit->setLabel ( 'Criar' );
		
		$form = new Zend_Form ( );
		$form->setAction ( '/tasks/create' )
				->setMethod ( 'post' )
				->addElement ( $assunto )
				->addElement ( $tarefa )
				->addElement ( $users )
				->addElement ( $date )
				->addElement ( $submit );
		return $form;
	
	}

}

?>